.PHONY: prepare comp run wave_show dc_compile clean

# TOP = LilyRiscv_top
export TOP = tb_comp_test
FILELIST = filelist.f
FSDB_TCL = dump_fsdb.tcl
export WAVE_fsdb = wave.fsdb
DC_TCL = dc_compile.tcl
OUT = out

prepare:
	mkdir -p $(OUT)
	mkdir -p $(OUT)/csrc

comp: prepare
	vcs -sverilog +v2k -debug_all -full64 -timescale=1ns/1ps \
	-f $(FILELIST) \
	-top $(TOP) \
	-Mdir=$(OUT)/csrc -l $(OUT)/compile.log -o $(OUT)/simv

run: prepare
	./$(OUT)/simv -ucli -i $(FSDB_TCL) \
	-l $(OUT)/run.log

wave_show: prepare
	verdi -sv -f $(FILELIST) -ssf $(WAVE_fsdb) +fsdb+autoflush

dc_compile: prepare
	dc_shell -f $(DC_TCL) -output_log_file ./$(OUT)/dc_compile.log

clean:
	rm -rf $(OUT)
	rm -rf novas* ucli.key verdiLog
	rm -rf *.mr *.pvl *.syn *.log *.svf
